<!--{layout:Header}-->
<div class="menu">
    <h1>添加书签</h1>
    <a class="logo" href="<!--{:Config::get('baseUrl')}-->">主页</a> </div>
<div class="form">
    <div>
        <select id="link_cid">
            <!--{foreach($categoryList as $v)}-->
            <option value="<!--{$v['id']}-->"><!--{:H($v['name'])}--></option>
            <!--{/foreach}-->
        </select>
    </div>
    <div <!--{if($isAdded)}-->style="border-color: red;"<!--{/if}-->>
        <input id="link_url" type="text" placeholder="网址" value="<!--{if($link)}--><!--{:H($link['url'])}--><!--{/if}-->" />
    </div>
    <div><input id="link_title" type="text" placeholder="标题" value="<!--{if($link)}--><!--{:H($link['title'])}--><!--{/if}-->" /></div>
    <div class="submit"><a href="javascript:;" id="link_add_save">保存</a></div>
</div>
<script type="text/javascript">
$("#link_add_save").click(function() {
    el = $(this);
    if(el.data("lock")) return;
    el.data("lock", 1);

    var url = "<!--{:Router::buildUrl('Link_Add')}-->";
    var data = {};
    data.cid = $("#link_cid").val();
    data.url = $("#link_url").val();
    data.title = $("#link_title").val();
    data._token = get_token();
    $.post(url, data, function(r) {
        alert(r.msg);
        if(r.status) {
            var cid = r.data;
            location.href = "<!--{:Config::get('baseUrl')}-->";
        }
        el.data("lock", 0);
    }, "json");
});
</script>
<!--{layout:Footer}-->
